#include "Explosion.h"
#include "Animation.h"
#include "RenderManager.h"
#include "Resources.h"

Explosion::Explosion(const sf::Vector2f& position)
{
	_position = position;
	_dimension = sf::Vector2f(42.0f, 42.0f);
	_anim = new Animation("", 0, 0, 5, 0, 100);
	_killMe = false;
	Resources::getSingletonPtr()->loadSprite(_sprite, "EXPLO_01");
	_sprite.setPosition(position);
	_anim->_done = false;
}


Explosion::~Explosion(void)
{
	delete _anim;
}

void Explosion::update()
{
	if (_anim->done())
		_killMe = true;
	_anim->update();
}

void Explosion::draw(RenderManager* rm)
{
	sf::IntRect rect = _sprite.getTextureRect();
	rect.left = _anim->getCurrentFrame() * rect.width;
	_sprite.setTextureRect(rect);
	rm->draw(_sprite);
}